﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public enum StrageType
{
    Separation,
    Queue,
    Gather
}


/// <summary>
/// 策略模式  计算集群中的各种力的作用
/// </summary>
public abstract class IStrategy
{
    //附近的个体
    protected List<GameObject> mNearbyCrowList = new List<GameObject>();
    //个体位置
    protected Transform mTransform;
    //队列力权重
    protected float mForceWeight;
    //附近施加队列力的范围半径
    protected float mNearbyRadium;

    public IStrategy(Transform transform, float nearbyRadium, float forceWeight = 1)
    {
        this.mTransform = transform;
        this.mNearbyRadium = nearbyRadium;
        this.mForceWeight = forceWeight;

        //获取附近的鸟
        FoundNearbyCrow();
    }

    public abstract Vector3 GetForce();

    protected List<GameObject> FoundNearbyCrow()
    {
        mNearbyCrowList.Clear();
        //使用物理检测出附近的个体
        Collider[] collider = Physics.OverlapSphere(this.mTransform.position, mNearbyRadium);
        foreach (var item in collider)
        {
            if (item != null && item.gameObject != this.mTransform.gameObject)
            {
                mNearbyCrowList.Add(item.gameObject);
            }
        }

        return mNearbyCrowList;
    }
}
